package com.study.jyg.rxjava2study.activity;

import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import androidx.appcompat.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.study.jyg.rxjava2study.R;
import com.study.jyg.rxjava2study.base.BasicActivity;
import com.study.jyg.rxjava2study.utils.glide.GlideUtils;

public class PrescribingSuccessActivity extends BasicActivity {

    private String fileName;
    private ImageView ivSign;


    @Override
    protected boolean isWithoutUseStatusBarColor() {
        return false;
    }

    @Override
    protected int getStatusBarColor() {
        return R.color.colorWhite;
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_prescribing_successly;
    }

    @Override
    protected void initView() {
        Toolbar toolbar = findViewById(R.id.toolBarLyout);
        TextView tvTitle = findViewById(R.id.tvTitle);
        tvTitle.setText("开方成功");
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(v -> finish());

        Bundle bundle = getIntent().getExtras();
        if (bundle != null){
            fileName = bundle.getString("fileName", "");
        }
        String path =  Environment.getExternalStorageDirectory().getPath()+"/"+fileName;
        ivSign = findViewById(R.id.ivSign);
        Glide.with(mContext).load(path)
                .apply(new RequestOptions()
                        .error(R.mipmap.ic_preview_image)
                        .placeholder(R.mipmap.ic_preview_image)
                        .dontAnimate()//支持圆形自定义imageview加载
                        .diskCacheStrategy(DiskCacheStrategy.NONE)//不使用缓存
                        .skipMemoryCache(true)//如果内存不足不缓存
                )
                .thumbnail(0.5f)//压缩
                .into(ivSign);
    }
}